﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace RobotCtrl
{
	public abstract class Track
	{
		public double speed;
		public double acceleration;
		public double length;
		public double pause;

	}

	public class TrackPause : Track
	{
		public TrackPause(double pauseTimeSeconds)
		{
			this.pause = pauseTimeSeconds;
		}
	}

	public class TrackLine : Track
	{
		public TrackLine(double length, double speed, double acceleration)
		{
			if ((Math.Sign(length) ^ Math.Sign(speed)) != 0)
				speed = -speed;
			this.speed = speed;
			this.acceleration = acceleration;
			this.length = length;
		}
	}

	public class TrackArcLeft : Track
	{
        public double angle;
        public double radius;

		public TrackArcLeft(double radius, double angle, double speed, double acceleration)
		{
			if ((Math.Sign(angle) ^ Math.Sign(speed)) != 0)
				speed = -speed;
			this.speed = speed;
			this.acceleration = acceleration;
			this.angle = angle;
			this.radius = radius;
			this.length = (radius + Config.AxleLength / 2.0) * 2.0 * Math.PI * angle / 360.0;
		}

	}

	public class TrackArcRight : Track
	{
		public TrackArcRight(double radius, double angle, double speed, double acceleration)
		{
			if ((Math.Sign(angle) ^ Math.Sign(speed)) != 0)
				speed = -speed;
			this.speed = speed;
			this.acceleration = acceleration;
			this.angle = angle;
			this.radius = radius;
			this.length = (radius + Config.AxleLength / 2.0) * 2.0 * Math.PI * angle / 360.0;
		}

		public double angle;
		public double radius;
	}

	public class TrackTurn : Track
	{
		public TrackTurn(double angle, double speed, double acceleration)
		{
			if ((Math.Sign(angle) ^ Math.Sign(speed)) != 0)
				speed = -speed;
			this.speed = speed;
			this.acceleration = acceleration;
			this.angle = angle;
			this.length = Config.AxleLength / 2.0 * 2.0 * Math.PI * angle / 360.0;
		}

		public double angle;
	}

    public class TrackRadar : Track
    {
        public double angle;
        public bool stop = false;

        public TrackRadar(double speed, double acceleration)
        {
            if ((Math.Sign(length) ^ Math.Sign(speed)) != 0)
                speed = -speed;
            this.speed = speed;
            this.acceleration = acceleration;
            this.length = 0; //runs for ever, hack
            this.angle = 0.5; //test
        }

        /// <summary>
        /// Here we stop to run the track
        /// </summary>
        public void Stop()
        {
            stop = true;
            this.length = 0.5;
        }

    }

}
